home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 344_01 / nrnd54.c < prev    next >
Text File  |  1990-05-18  |  811b  |  34 lines

  1. /*
  2. HEADER:         ;
  3. TITLE:          5/4 rouding routine
  4. VERSION:        1.0;
  5.  
  6. DESCRIPTION:    given a value to round and no. of digits desired, return
  7.                 the rouded number
  8.  
  9. KEYWORDS:       5/4, rounding;
  10. SYSTEM:         Xenix 3.4b, MSDOS;
  11. FILENAME:       nrnd54.c;
  12. WARNINGS:
  13.  
  14. SEE-ALSO:       ;
  15. AUTHORS:        Vern Martin, 449 W. Harrison, Alliance, Ohio 44601;
  16. COMPILERS:      ECOSOFT ECO-C88, XENIX 3.4B STANDARD COMPILER;
  17. */
  18.  
  19. #include "vernmath.h"
  20.  
  21. double nrnd54(value,digits)
  22. double value;   /* value to round                  */
  23. int digits;     /* number of digits to of accuracy */
  24. {
  25.     double f;
  26.  
  27. #define F_M1 (((pow(10.0,(double)((digits)*-1))))*.5)
  28. #define rounded (((long)((value+F_M1)*f))/f)
  29.  
  30.     f = pow(10.0,(double)digits);
  31.  
  32.     return(rounded);
  33. }
  34.